home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / curses.h < prev    next >
C/C++ Source or Header  |  1990-04-09  |  5KB  |  174 lines

  1. /*
  2.  * Copyright (c) 1980 Regents of the University of California.
  3.  * All rights reserved.  The Berkeley software License Agreement
  4.  * specifies the terms and conditions for redistribution.
  5.  *
  6.  *    @(#)curses.h    5.1 (Berkeley) 6/7/85
  7.  */
  8.  
  9. # ifndef WINDOW
  10.  
  11. # include    <stdio.h>
  12.  
  13. # include    <sgtty.h>
  14.  
  15. # define    bool    char
  16. # define    reg    register
  17.  
  18. # define    TRUE    (1)
  19. # define    FALSE    (0)
  20. # define    ERR    (0)
  21. # define    OK    (1)
  22.  
  23. # define    _ENDLINE    001
  24. # define    _FULLWIN    002
  25. # define    _SCROLLWIN    004
  26. # define    _FLUSH        010
  27. # define    _FULLLINE    020
  28. # define    _IDLINE        040
  29. # define    _STANDOUT    0200
  30. # define    _NOCHANGE    -1
  31.  
  32. # define    _puts(s)    tputs(s, 0, _putchar)
  33.  
  34. typedef    struct sgttyb    SGTTY;
  35.  
  36. /*
  37.  * Capabilities from termcap
  38.  */
  39.  
  40. extern bool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
  41.         XB, XN, XT, XS, XX;
  42. extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
  43.         *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
  44.         *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
  45.         *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
  46.         *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
  47.         *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
  48.         *LEFT_PARM, *RIGHT_PARM;
  49. #ifdef    __NeXT__
  50. #undef    PC
  51. #endif    __NeXT__
  52. extern char    PC;
  53.  
  54. /*
  55.  * From the tty modes...
  56.  */
  57.  
  58. extern bool    GT, NONL, UPPERCASE, normtty, _pfast;
  59.  
  60. struct _win_st {
  61.     short        _cury, _curx;
  62.     short        _maxy, _maxx;
  63.     short        _begy, _begx;
  64.     short        _flags;
  65.     short        _ch_off;
  66.     bool        _clear;
  67.     bool        _leave;
  68.     bool        _scroll;
  69.     char        **_y;
  70.     short        *_firstch;
  71.     short        *_lastch;
  72.     struct _win_st    *_nextp, *_orig;
  73. };
  74.  
  75. # define    WINDOW    struct _win_st
  76.  
  77. extern bool    My_term, _echoit, _rawmode, _endwin;
  78.  
  79. extern char    *Def_term, ttytype[];
  80.  
  81. extern int    LINES, COLS, _tty_ch, _res_flg;
  82.  
  83. extern SGTTY    _tty;
  84.  
  85. extern WINDOW    *stdscr, *curscr;
  86.  
  87. /*
  88.  *    Define VOID to stop lint from generating "null effect"
  89.  * comments.
  90.  */
  91. # ifdef lint
  92. int    __void__;
  93. # define    VOID(x)    (__void__ = (int) (x))
  94. # else
  95. # define    VOID(x)    (x)
  96. # endif
  97.  
  98. /*
  99.  * psuedo functions for standard screen
  100.  */
  101. # define    addch(ch)    VOID(waddch(stdscr, ch))
  102. # define    getch()        VOID(wgetch(stdscr))
  103. # define    addstr(str)    VOID(waddstr(stdscr, str))
  104. # define    getstr(str)    VOID(wgetstr(stdscr, str))
  105. # define    move(y, x)    VOID(wmove(stdscr, y, x))
  106. # define    clear()        VOID(wclear(stdscr))
  107. # define    erase()        VOID(werase(stdscr))
  108. # define    clrtobot()    VOID(wclrtobot(stdscr))
  109. # define    clrtoeol()    VOID(wclrtoeol(stdscr))
  110. # define    insertln()    VOID(winsertln(stdscr))
  111. # define    deleteln()    VOID(wdeleteln(stdscr))
  112. # define    refresh()    VOID(wrefresh(stdscr))
  113. # define    inch()        VOID(winch(stdscr))
  114. # define    insch(c)    VOID(winsch(stdscr,c))
  115. # define    delch()        VOID(wdelch(stdscr))
  116. # define    standout()    VOID(wstandout(stdscr))
  117. # define    standend()    VOID(wstandend(stdscr))
  118.  
  119. /*
  120.  * mv functions
  121.  */
  122. #define    mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
  123. #define    mvwgetch(win,y,x)    VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
  124. #define    mvwaddstr(win,y,x,str)    VOID(wmove(win,y,x)==ERR?ERR:waddstr(win,str))
  125. #define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
  126. #define    mvwinch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
  127. #define    mvwdelch(win,y,x)    VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
  128. #define    mvwinsch(win,y,x,c)    VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
  129. #define    mvaddch(y,x,ch)        mvwaddch(stdscr,y,x,ch)
  130. #define    mvgetch(y,x)        mvwgetch(stdscr,y,x)
  131. #define    mvaddstr(y,x,str)    mvwaddstr(stdscr,y,x,str)
  132. #define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
  133. #define    mvinch(y,x)        mvwinch(stdscr,y,x)
  134. #define    mvdelch(y,x)        mvwdelch(stdscr,y,x)
  135. #define    mvinsch(y,x,c)        mvwinsch(stdscr,y,x,c)
  136.  
  137. /*
  138.  * psuedo functions
  139.  */
  140.  
  141. #define    clearok(win,bf)     (win->_clear = bf)
  142. #define    leaveok(win,bf)     (win->_leave = bf)
  143. #define    scrollok(win,bf) (win->_scroll = bf)
  144. #define flushok(win,bf)     (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
  145. #define    getyx(win,y,x)     y = win->_cury, x = win->_curx
  146. #define    winch(win)     (win->_y[win->_cury][win->_curx] & 0177)
  147.  
  148. #define raw()     (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, stty(_tty_ch,&_tty))
  149. #define noraw()     (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty))
  150. #define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, stty(_tty_ch,&_tty))
  151. #define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,stty(_tty_ch,&_tty))
  152. #define crmode() cbreak()    /* backwards compatability */
  153. #define nocrmode() nocbreak()    /* backwards compatability */
  154. #define echo()     (_tty.sg_flags |= ECHO, _echoit = TRUE, stty(_tty_ch, &_tty))
  155. #define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, stty(_tty_ch, &_tty))
  156. #define nl()     (_tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty))
  157. #define nonl()     (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, stty(_tty_ch, &_tty))
  158. #define    savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
  159. #define    resetty() (_tty.sg_flags = _res_flg, (void) stty(_tty_ch, &_tty))
  160.  
  161. #define    erasechar()    (_tty.sg_erase)
  162. #define    killchar()    (_tty.sg_kill)
  163. #define baudrate()    (_tty.sg_ospeed)
  164.  
  165. WINDOW    *initscr(), *newwin(), *subwin();
  166. char    *longname(), *getcap();
  167.  
  168. /*
  169.  * Used to be in unctrl.h.
  170.  */
  171. #define    unctrl(c)    _unctrl[(c) & 0177]
  172. extern char *_unctrl[];
  173. # endif
  174.